/*
 * test_code.cpp
 *
 *  Created on: Mar 11, 2014
 *      Author: killerg
 */

#include <set>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
std::set<int64_t> gained;

/* return string representation of num in base rad as new string (or NULL) */
char *toBaseWhatever(int64_t num, int rad)
{
    char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    int i;
    char buf[66];   /* enough space for any 64-bit in base 2 */

    /* bounds check for radix */
    if (rad < 2 || rad > 62)
        return NULL;
    /* if num is zero */
    if (!num)
        return strdup("0");

    /* null terminate buf, and set i at end */
    buf[65] = '\0';
    i = 65;

    if (num > 0) {  /* if positive... */
        while (num) { /* until num is 0... */
            /* go left 1 digit, divide by radix, and set digit to remainder */
            buf[--i] = digits[num % rad];
            num /= rad;
        }
    } else {    /* same for negative, but negate the modulus and prefix a '-' */
        while (num) {
            buf[--i] = digits[-(num % rad)];
            num /= rad;
        }
        buf[--i] = '-';
    }
    /* return a duplicate of the used portion of buf */
    return buf + i;
}

bool test_code() {

	for (int i=-2; i<1000; ++i) {
		printf("%d\t%d\n", i, 1<<i);
	}
//
//	for (int64_t i=0; gained.size() < 10000000; ++i) {
//		int64_t m_RandomKey = (unsigned int64_t) rand() << 32 | rand();
//		gained.insert(m_RandomKey % 1000000000000000000);
//	}
//
//
//	auto file = fopen("numcodes.txt", "w");
//
//
//	for (auto itr : gained) {
//		fprintf(file, "%010.10s\n", toBaseWhatever(itr, 36));
//	}
//
//	fclose(file);


	return true;
}
